
using Youz.Common.Helper;
using Youz.Common.DAL;
using Youz.Common.Entity;
using System;
using System.Data;
using System.Data.SqlClient;
using System.Collections.Generic;

namespace Youz.Common.BLL
{
    /// <summary>
    /// Right_MemberRole BLL Class
    /// </summary>
    public partial class Right_MemberRoleBLL : BaseBLL
    {
		Right_MemberRoleDAL dal;
        /// <summary>
        /// 特殊角色ID，來自Web.config
        /// </summary>
        public Guid SpecialRoleID
        {
            get
            {
                return ConfigHelper.GetConfigGuid("SpecialRoleID");
            }
        }
        public Right_MemberRoleBLL()
        {
            base.MenuName = "安全管理";
            base.ModuleName = "用戶角色設置";
			dal = new Right_MemberRoleDAL();
		}

        #region  成员方法
        /// <summary>
        ///  新增一条数据
        /// </summary>
        public bool Add(Right_MemberRole model)
        {
            var r = dal.Add(model);
            base.WriteOperationLog(OperationType.Add, r, Utility.GetJsonByObject(model));
            return r;
        }

        public bool Add(string MemberAccountS, Guid role)
        {
            var r = dal.Add(MemberAccountS, role);
            base.WriteOperationLog(OperationType.Update, r, string.Format("{0}, Menus={1}", role.ToString(), MemberAccountS));
            return r;
        }

        public List<Right_MemberRole> Gets(Guid roleID)
        {
            return new EntityHelper<Right_MemberRole>().FillEntity(this.Gets(string.Format("RoleID='{0}'", roleID)));
        }

        /// <summary>
        ///  保存一条数据
        /// </summary>
        public bool Update(Right_MemberRole model)
        {
            return dal.Update(model);
        }

        /// <summary>
        /// 删除一条数据
        ///</summary>
        public bool Delete(String MemberAccount, SiteType type)
        {
            return dal.Delete(MemberAccount, type);
        }

        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Right_MemberRole Get(String MemberAccount, SiteType type)
        {
            return dal.Get(MemberAccount, type);
        }
        /// <summary>
        /// 检查对象是否存在
        /// </summary>
        public bool Exists(Guid roleID)
        {
            return dal.Exists(roleID);
        }
		
		/// <summary>
        /// 得到一个JSON对象
        /// </summary>
        public string GetJson(String MemberAccount, SiteType type)
        {
            return Utility.GetJsonByObject(Get(MemberAccount, type));
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet Gets(string sqlWhere)
        {
            return dal.Gets(sqlWhere);
        }
		
		/// <summary>
        /// 获得前几行数据
        /// </summary>
        public DataSet Gets(int top, string sqlWhere, string filedOrder)
        {
            return dal.Gets(top, sqlWhere, filedOrder);
        }
		
		/// <summary>
        /// 获取记录总数
        /// </summary>
        public int GetRecordCount(string sqlWhere)
        {
            return dal.GetRecordCount(sqlWhere);
        }
		
		/// <summary>
        /// 获得数据列表分页
        /// </summary>
        public DataTable Gets(string sqlWhere, int pageindex, int pagesize, out int total, params SqlParameter[] cmdParms)
        {
            return dal.Gets(sqlWhere, pageindex, pagesize, out total, cmdParms);
        }
        #endregion  成员方法

        public DataTable GetRoleMemberList(string sqlWhere, int pageindex, int pagesize, out int total, params SqlParameter[] cmdParms)
        {
            return dal.GetRoleMemberList(sqlWhere,pageindex,pagesize, out total, cmdParms);
        }

        /// <summary>
        /// 是否存在该记录
        /// </summary>
        public bool Exists(string MemberAccount, Guid RoleID)
        {
            return dal.Exists(MemberAccount, RoleID);
        }

        /// <summary>
        /// 删除一条数据
        ///</summary>
        public bool Delete(string MemberAccount, Guid RoleID)
        {
            var r = dal.Delete(MemberAccount, RoleID);
            base.WriteOperationLog(OperationType.Delete, r, string.Format("{0} {1}", MemberAccount, RoleID));
            return r;
        }
    }
}


  